//package com.example.friendfindertwo.data.helper;
//
//import java.util.ArrayList;
//import java.util.Date;
//import java.util.List;
//import java.text.ParseException;
//import java.text.SimpleDateFormat;
//
//import model.Event;
//
//import com.example.friendfindertwo.model.Friend;
//import com.google.android.gms.maps.model.LatLng;
//
//import android.content.ContentValues;
//import android.content.Context;
//import android.database.Cursor;
//import android.database.SQLException;
//import android.database.sqlite.SQLiteDatabase;
//import android.util.Log;
//
//public class EventDAO extends AbstractDAO{
//	
//	final SimpleDateFormat parser = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.sss");
//	private Context context;
//	private FriendDAO friendDao;
//	
//	public EventDAO(){
////		super(context);
////		this.context = context;
//		friendDao = new FriendDAO();
//	}
//	
////	public void open() throws SQLException{
////		database = dbHelper.getWritableDatabase();
////	}
////	
////	public void close(){
////		dbHelper.close();
////	}
//	
//	public Event createEvent(String title, int categoryId, String description, Date creationDate, Date startDate, Date endDate, String placeName, LatLng location, Friend creator){
//		//Log.i("DAO createEvent", creator.getFriendName());
//
////		friendDao = new FriendDAO();
//		
//		ContentValues values = new ContentValues();
//		values.put(EventTable.COLUMN_TITLE, title);
//		values.put(EventTable.COLUMN_CATEGORY, categoryId);
//		values.put(EventTable.COLUMN_CREATION_DATE, parser.format(creationDate));
//		values.put(EventTable.COLUMN_START_DATE, parser.format(startDate));
//		values.put(EventTable.COLUMN_END_DATE, parser.format(endDate));
//		
//		values.put(EventTable.COLUMN_CREATOR, friendDao.getId(creator));
//		if(description != null || !description.isEmpty()){
//			values.put(EventTable.COLUMN_DESCRIPTION, description);
//		}else{
//			values.put(EventTable.COLUMN_DESCRIPTION, "no description");
//		}
//		values.put(EventTable.COLUMN_PLACE_NAME, placeName);
//		values.put(EventTable.COLUMN_POSITION_LATITUDE, location.latitude);
//		values.put(EventTable.COLUMN_POSITION_LONGITUDE, location.longitude);
//		
//		long insertId = database.insert(EventTable.TABLE_EVENT, null, values);
//		
//		// troubles here no such column select id 
//		Cursor cursor = database.query(EventTable.TABLE_EVENT, null, EventTable.COLUMN_ID + " = " + insertId, null, null, null, null);
//		cursor.moveToFirst();
//		Event event = cursorToEvent(cursor);
//		
////		Cursor cursor = database.query(EventTable.TABLE_EVENT, null, null, null, null, null, null);
//		
////		cursor.moveToFirst();
////		while(!cursor.isAfterLast()){
////			//Log.i("Success", "Friend " + cursor.getString(1) + " was created");
////			Log.i("Success", "DAO create Event " + cursor.getInt(0) + " was created");
////			cursor.moveToNext();
////		}
//		
//		return event;
//		//return null;
//	}
//	
////	public Event createEvent(Event event){
////		ContentValues values = new ContentValues();
////		values.put(EventTable.COLUMN_TITLE, event.getTitle());
////		values.put(EventTable.COLUMN_CATEGORY, categoryId);
////		values.put(EventTable.COLUMN_CREATION_DATE, parser.format(event.getCreationDate()));
////		values.put(EventTable.COLUMN_START_DATE, parser.format(event.getStartDate()));
////		values.put(EventTable.COLUMN_END_DATE, parser.format(event.getEndDate()));
////		values.put(EventTable.COLUMN_CREATOR, creatorId);
////		values.put(EventTable.COLUMN_DESCRIPTION, event.getDescription());
////		values.put(EventTable.COLUMN_PLACE_NAME, event.getPlaceName());
////		long insertId = database.insert(EventTable.TABLE_EVENT, null, values);
////		Cursor cursor = database.query(EventTable.TABLE_EVENT, allColumns, EventTable.COLUMN_ID + " = " + insertId, null, null, null, null);
////		cursor.moveToFirst();
////		Event resultEvent = cursorToEvent(cursor);
////		return resultEvent;
////	}
//	
//	private Event cursorToEvent(Cursor cursor){
//		Event event = new Event();
//		event.setTitle(cursor.getString(cursor.getColumnIndex(EventTable.COLUMN_TITLE)));
//		event.setDescription(cursor.getString(cursor.getColumnIndex(EventTable.COLUMN_DESCRIPTION)));
//		event.setCategorie(cursor.getString(cursor.getColumnIndex(EventTable.COLUMN_CATEGORY)));
//		event.setPlaceName(cursor.getString(cursor.getColumnIndex(EventTable.COLUMN_PLACE_NAME)));
//		LatLng location = new LatLng(cursor.getDouble(cursor.getColumnIndex(EventTable.COLUMN_POSITION_LATITUDE)), cursor.getDouble(cursor.getColumnIndex(EventTable.COLUMN_POSITION_LONGITUDE)));
//		event.setPosition(location);
//		try {
//			event.setCreationDate(parser.parse(cursor.getString(cursor.getColumnIndex(EventTable.COLUMN_CREATION_DATE))));
//			event.setStartDate(parser.parse(cursor.getString(cursor.getColumnIndex(EventTable.COLUMN_START_DATE))));
//			event.setEndDate(parser.parse(cursor.getString(cursor.getColumnIndex(EventTable.COLUMN_END_DATE))));
//		} catch (ParseException e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//			Log.i("Excpetion","event date parse exception");
//		}
//		event.setCreator(friendDao.getFriendById(Integer.parseInt(cursor.getString(cursor.getColumnIndex(EventTable.COLUMN_CREATOR)))));
//		
//		return event;
//	}
//	
//	public List<Event> getAllEvents(){
//		List<Event> events = new ArrayList<Event>();
//		Cursor cursor = database.query(EventTable.TABLE_EVENT, null, null, null, null, null, null);
//		if(cursor != null){
//			cursor.moveToFirst();
//			while(!cursor.isAfterLast()){
//				Event event = cursorToEvent(cursor);
//				events.add(event);
//				cursor.moveToNext();
//			}
//			cursor.close();
//		}
//		return events;
//	}
//	
//public Event getEventById(int id){
//		
//		Log.i("EventDAO friend by id",""+ id);
//		
////		Cursor cursor = super.database.query(FriendTable.TABLE_FRIEND, new String[]{ FriendTable.COLUMN_ID, FriendTable.COLUMN_NAME },
////										FriendTable.COLUMN_ID + " = ", new String[]{String.valueOf(id)}, null, null, null, null);
//		
//		Cursor cursor = super.database.query(EventTable.TABLE_EVENT, null,
//				EventTable.COLUMN_ID + " = "+ id, null, null, null, null);
//		
//		if(cursor != null && cursor.getCount()>1){
//			cursor.moveToFirst();
//			Event event = cursorToEvent(cursor);
//			Log.i("Success", "Friend " + cursor.getString(cursor.getColumnIndex(FriendTable.COLUMN_NAME)) + " was created");
//			return event;
//		}else{
//			Log.i("Error", "cursor in getFriendById is null or lower than one");
//		}
//		return null;
//	}
//
//}
